package RJZ.Rainbow.Config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@PropertySource("classpath:connection.properties")
@Component
public class Information {
    String ip;
    int port;
    String id;
    String code;


    public Information(@Value("${server.ip}") String ip,
                       @Value("${server.port}") int port,
                       @Value("${boxid}") String boxid) {
        this.ip = ip;
        this.port = port;
        this.id=boxid;
        SimpleDateFormat DATE = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss");
        String D = DATE.format(new Date());
        String time = D.replace("-", "");
        setCode(boxid+time+boxid);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

}
